Skip to main content

Install Docker Using Minikube on MacOS

Since Docker Desktop is a subscription product, some users will need an alternative means of installing Docker. This guide describes the process of using Minikube as a replacement, but it comes with limitations such as the need to explicitly mount every docker-mounted directory in Minikube first.

The reason Minikube works as an alternative to Docker Desktop is because it manages an installation of Docker on a virtual machine. Docker can't be installed directly on MacOS or Windows and must run inside a linux virtual machine.

Steps

Install Hyperkit

To install Minikube, a virtual machine backend must be installed. Here we used Hyperkit but Virtualbox is a suitable alternative too.

brew install hyperkit

Install Docker CLI

Use brew to install the Docker CLI.

brew install docker

Install Minikube

Use brew to install Minikube too.

brew install minikube

Config Minikube

If you intend to run many containers, you can increase Minikube's resource limits as follows:

minikube config set cpus 6
minikube config set memory 12g

Start cluster

To spin up the Minikube cluster, use the following command:

minikube start --driver=hyperkit --container-runtime=docker

Set environment variables

The following command will set environment variables telling the Docker CLI to talk to the Docker server managed by Minikube.

eval $(minikube docker-env)

Install docker-compose

To use docker-compose, install it with brew:

brew install docker-compose

Usage

Turn off Kubernetes

If you don't need the Kubernetes cluster, you can use the command minikube pause to pause Kubernetes but keep the Docker daemon running. Use minikube unpause to start the Kubernetes services again.

Mounting volumes

Mounting volumes on your host machine in Docker containers won't work out of the box. You first have to mount the files from the host machine into the Minikube VM.

Use the command minikube mount /hostdirectory:/vmdirectory to create the Host/VM mount. Subsequently, the command to run a docker container that mounts this directory would be docker run --rm -it -v /vmdirectory:/containerdirectory busybox /bin/sh .

Potential issues

Fix config.json

If you're switching from Docker Desktop to Minikube, you might need to change a key in your Docker config:

Open up ~/.docker/config.json and change "credsStore" key to "credStore" (if it's not set correctly already)